package com.huarui.companydeal.service;

import java.util.List;
import java.util.Map;

import org.ewaf.framework.model.PagingInfo;
import org.ewaf.framework.service.BaseService;

import com.huarui.companydeal.dao.ICompanyDealDao;
import com.huarui.companydeal.model.CompanyDeal;
import com.huarui.user.model.SessionMessage;
import com.huarui.user.security.UserHolder;

public class CompanyDealService extends BaseService {
	private ICompanyDealDao getDao() {
		return (ICompanyDealDao) dao;
	}

	public void getCompanyDealsByCondition(PagingInfo<Map<String, Object>, CompanyDeal> pagingInfo) {
		SessionMessage sessionMessage = UserHolder.getCurrentSessionMessage();
		Map<String, Object> queryMap = pagingInfo.getCondition();
		queryMap.put("companyId", sessionMessage.getCompanyId());
		Integer count = getDao().getCompanyDealCountByCondition(queryMap);
		queryMap.put("start", pagingInfo.getStart());
		queryMap.put("limit", pagingInfo.getLimit());
		List<CompanyDeal> companyDeals = getDao().getCompanyDealsByCondition(queryMap);
		pagingInfo.setItems(companyDeals);
		pagingInfo.setTotal(count);
	}

}
